//
//  ViewController.m
//  runloop让线程保活封装版
//
//  Created by Hello Cai on 2021/7/27.
//

#import "ViewController.h"
#import "HRPermanentThread.h"

@interface ViewController ()
@property(nonatomic, strong)HRPermanentThread *thread;
@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    self.thread = [[HRPermanentThread alloc] init];
}

-(void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
    [self.thread executeBlock:^{
        NSLog(@"执行任务 - %@", [NSThread currentThread]);
    }];
}

-(void)task{
    NSLog(@"执行任务：%s %@", __func__, [NSThread currentThread]);
}

- (IBAction)stopThread:(id)sender {
    [self.thread stop];
}

-(void)dealloc{
    NSLog(@"%s", __func__);
}
@end
